/*
 * @Date: 2022-03-02 10:32:10
 * @LastEditors: 春贰
 * @gitee: https://gitee.com/chun22222222
 * @github: https://github.com/chun222
 * @Desc:备份
 * @LastEditTime: 2022-03-24 17:22:40
 * @FilePath: \server\system\service\RecordService\record.go
 */

package RecordService

import (
	"go2admin_pure/system/core/db"
	"go2admin_pure/system/core/request"
	"go2admin_pure/system/model/DbModel"
	"go2admin_pure/system/model/RequestModel"
)

type RecordService struct{}

//分页列表
func (recordService *RecordService) List(info RequestModel.SysRecord) (err error, list interface{}, total int64) {
	limit := info.PageSize
	offset := info.PageSize * (info.Page - 1)

	db := db.Instance().Model(&DbModel.SysRecord{})
	//动态查询条件
	request.GenWhere(info, db)
	var dataList []DbModel.SysRecord
	err = db.Count(&total).Error
	if err != nil {
		return
	}
	err = db.Limit(limit).Offset(offset).Order("create_time desc").Find(&dataList).Error
	return err, dataList, total
}
